extends Control

var conf_path = Globals.user_data_folder + "conf.tres"
var user_data = UserData.new()

func _ready():
	if ResourceLoader.exists(conf_path):
		var conf = ResourceLoader.load(conf_path)
		if conf is UserData:
			Globals.current_user = conf.user_name
	if not Globals.current_user:
		$VBoxContainer/SkirmishButton.disabled = true
		$VBoxContainer/DeckButton.disabled = true

func _on_QuitButton_pressed():
	get_tree().quit()


func _on_DeckButton_pressed():
	get_tree().change_scene("res://UIScenes/DeckUIv2.tscn")


func _on_SkirmishButton_pressed():
	get_tree().change_scene("res://UIScenes/MapViewer.tscn")


func _on_UserSelect_got_user(name):
	$VBoxContainer/SkirmishButton.disabled = false
	$VBoxContainer/DeckButton.disabled = false
	user_data.user_name = name
	ResourceSaver.save(conf_path, user_data)
